
package br.com.eSink.util;

import java.io.IOException;
import java.net.InetAddress;

public class CheckThread implements Runnable {

    int i;
    String subnet;
    IPAddress ipa;
    public CheckThread(int i, String subnet, IPAddress ipa) {
        this.i=i;
        this.subnet=subnet;
        this.ipa=ipa;
    }

    
    @Override
    public void run() {
       int timeout = 2000;
        String host = subnet + "." + i;
        try {            
            if (InetAddress.getByName(host).isReachable(timeout)) { 
                this.ipa.ips.add(host);
            }
        } catch (IOException ex) {
            System.out.println("Problema para checar ip:"+ex.getMessage());
        } 
    }
    
}
